package com.chuangke.mds.service.impl;

import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.IndexOperations;
import org.springframework.stereotype.Service;

import com.chuangke.mds.entity.Knowledge;
import com.chuangke.mds.service.KnowledgeElasticService;
import com.chuangke.mds.service.KnowledgeService;

@Service
public class KnowledgeElasticServiceImpl implements KnowledgeElasticService {

//    @Autowired
//    private ElasticsearchTemplate elasticsearchTemplate;
//    @Autowired
//    private KnowledgeService knowledgeService;

    @Override
    public boolean exists() {
//        IndexOperations indexOperations = elasticsearchTemplate.indexOps(Knowledge.class);
//        return indexOperations.exists();
    	return true ;
    }

    @Override
    public void reIndex() {
//        IndexOperations indexOperations = elasticsearchTemplate.indexOps(Knowledge.class);
//        indexOperations.delete();
//        indexOperations.create();
    }

    @Override
    public void reSyncData() {
//        reIndex();
//
//        List<Knowledge> list = knowledgeService.getKnowledgeList();
//        if (!CollectionUtils.isEmpty(list)) {
//            elasticsearchTemplate.save(list);
//        }
    }
}
